package com.zwy.com.zwy.activti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.lang.annotation.Target;
import java.util.List;


/**
 * 查询任务
 * @author 天火
 * @className ActivitiTaskQuery
 */
public class ActivitiTaskQuery {

    public static void main(String[] arg){

        // 1.得到ProcessEngine对象
        String assignee= "李四";
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2.得到TaskService对象
        TaskService taskService = processEngine.getTaskService();
        //3.根据流程定义的可以，当前负责人assignee来实现对当前用户的任务列表
       /*List<Task> list = taskService.createTaskQuery()
                .processDefinitionKey("holiday")
                .taskAssignee("assignee")
                .list();*/
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("holiday")
                .taskAssignee(assignee)
                .singleResult();
        //4.任务展示


            System.out.println("流程实例Id: " + task.getProcessInstanceId());
            System.out.println("任务Id：" + task.getId());
            System.out.println("任务负责人：" + task.getAssignee());
            System.out.println("任务名称：" + task.getName());

    }
}
